<%--
 @author : Sisiruwan Senadeera
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript">

    function validate() {

        $("#create-alienation-method-formId").validate({
            rules:{
                nameOfAlienationEnglishId:{
                        required: true
                },
                nameOfAlienationSinhalaId:{
                        required: true
                },
                nameOfAlienationTamilId:{
                        required: true
                }
            },
            messages:{
                nameOfAlienationEnglishId:{
                        required: "<br/>" + $("#plsEnterAlienationMethodNameInEnID").val()
                },
                nameOfAlienationSinhalaId:{
                        required: "<br/>" + $("#plsEnterAlienationMethodNameInSiID").val()
                },
                nameOfAlienationTamilId:{
                        required: "<br/>" + $("#plsEnterAlienationMethodNameInTaID").val()
                }
            }
        });

    }

</script>

<div id="alienation-methods-module-home-title" class="module-home-title">
    <s:a href="home.do"><img src="${pageContext.request.contextPath}/images/interest-party.png"
                                   alt="User Module"><span><s:label
            value="%{getText('introduction_of_new_alianation_method.label')}"/></span></s:a>
    <div id="back-button" align="right">
        <s:submit type="input" value="%{getText('back.label')}" onclick="goBack();"/>
    </div>
</div>

<div class="page-title">
    <s:if test="editMode==0">
        <h2><s:label value="%{getText('create_new_alienation_method.label')}"/></h2>
    </s:if>
    <s:elseif test="editMode==1">
        <h2><s:label value="%{getText('update_alienation_method.label')}"/></h2>
    </s:elseif>

</div>

<div>
    <s:if test="hasActionErrors()">
        <s:div id="message-box" class="message-box">
            <div class="action-err">
                <s:label value="%{getText('error_occurred.label')}"/>
                <s:actionerror/>
            </div>
        </s:div>
    </s:if>
    <s:if test="hasActionMessages()">
        <s:div id="message-box" class="message-box">
            <div class="action-msg">
                <s:actionmessage/>
            </div>
        </s:div>
    </s:if>
</div>

<div id="creat-new-alienation-form-outer">
    <fieldset>
    <s:form method="POST" id="create-alienation-method-formId" name="create-alienation-method-formId" enctype="multipart/form-data"
            onsubmit="javascript:return validateFormForInputDataSyntaxErrors('create-alienation-method-formId')">
        <table>

            <s:if test="editMode==1" >
                <tr>
                    <td>
                        <s:label value="%{getText('alienation_method_id.label')}"/>
                    </td>
                    <td colspan="3"><s:textfield id="alienationMethodId"  name="alienationMethodId" cssClass="width-400-px" disabled="true"/></td>

                    <td></td>
                    <td></td>
                </tr>

            </s:if>

            <tr>
                <td>
                    <s:label value="%{getText('alienation_method_in_english.label')}"/> <span class="mandatory-field"></span>
                </td>
                <td colspan="3"><s:textfield id="nameOfAlienationEnglishId"  name="alienationMethod.enName" cssClass="width-400-px"/></td>

                <td></td>
                <td></td>
            </tr>
            <tr>
                <td>
                    <s:label value="%{getText('alienation_method_in_sinhala.label')}"/> <span class="mandatory-field"></span>
                </td>
                <td colspan="3"><s:textfield id="nameOfAlienationSinhalaId"  name="alienationMethod.siName" cssClass="width-400-px"/></td>

                <td></td>
                <td></td>
            </tr>
            <tr>
                <td>
                    <s:label value="%{getText('alienation_method_in_tanil.label')}"/> <span class="mandatory-field"></span>
                </td>
                <td colspan="3"><s:textfield id="nameOfAlienationTamilId"  name="alienationMethod.taName" cssClass="width-400-px"/></td>

                <td></td>
                <td></td>
            </tr>

            <tr>
                <td><s:label value="%{getText('purpose_of_alienation.label')}"/></td>
                <td colspan="3"><s:textarea id="purposeOfAlienationId"
                                             name="alienationMethod.purpose" cssClass="width-400-px" />
                </td>
                <td></td>
                <td></td>
            </tr>

            <tr>
                <td><s:label value="%{getText('alienation_methods_conditions_applicable.label')}"/></td>
                <td colspan="3"><s:textarea id="standardConditionsApplicableId" name="alienationMethod.standards"
                                 cssClass="width-400-px" rows="5"/>
                      </td>
                <td></td>
                <td></td>
            </tr>
        </table>
        <br>

        <div align="right">
            <table>
                <tr>
                    <td colspan="2">
                        <s:if test="editMode==0" >
                            <s:submit value="%{getText('save.label')}" action="createNewAlieanationMethod" onclick="validate()"/>
                        </s:if>
                        <s:elseif test="editMode==1">
                            <s:submit value="%{getText('update.label')}" action="updateAlienationMethod" onclick="validate()"/>
                        </s:elseif>
                        <s:submit value="%{getText('cancel.label')}" action="introduceNewAlienationMethodsModule"/>
                        <s:hidden name="landApplication.id"/>

                    </td>
                </tr>
            </table>
        </div>
        <s:hidden name="alienationMethodId"/>
    </s:form>
        </fieldset>
</div>
<s:hidden id="plsEnterAlienationMethodNameInEnID" value="%{getText('pls_Enter_Alienation_Method_Name_inen.label')}"/>
<s:hidden id="plsEnterAlienationMethodNameInSiID" value="%{getText('pls_enter_elienation_method_name_insi.label')}"/>
<s:hidden id="plsEnterAlienationMethodNameInTaID" value="%{getText('pls_enter_elienation_method_name_inta.label')}"/>


